package se.slp.test1;
import android.app.Activity;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import android.content.Intent;
import android.os.Bundle;

public class ConfirmData extends Activity{
	
	private TextView output,text_name;
	private DataHelper dh;
	private String strReceipInput1;
	private String strReceipInput2;
	private String strReceipInput3;
	private String strReceipInput4;
	private String strReceipInput5;
	private String strReceipInput6;
	private String strReceipInput7;
	
 /** Called when the activity is first created. */
	Intent launch_record;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		// TODO Auto-generated method stub
				super.onCreate(savedInstanceState);
				setContentView(R.layout.confirmdata);
				
				output = (TextView)findViewById(R.id.txtOutput);
				strReceipInput1 = getIntent().getStringExtra("strInput1");
				strReceipInput2 = getIntent().getStringExtra("strInput2");
				strReceipInput3 = getIntent().getStringExtra("strInput3");
				strReceipInput4 = getIntent().getStringExtra("strInput4");
				strReceipInput5 = getIntent().getStringExtra("strInput5");
				strReceipInput6 = getIntent().getStringExtra("strInput6");
				strReceipInput7 = getIntent().getStringExtra("strInput7");
				
				
				
				ImageButton button_ok = (ImageButton)findViewById(R.id.button_ok);
				
				button_ok.setOnClickListener(new OnClickListener() {
						
						public void onClick(View v) {
							// TODO Auto-generated method stub
							launch_record = new Intent(getApplicationContext(),Record.class); ////////////////////////////////
							launch_record.putExtra("strInput1", strReceipInput1);
							startActivity(launch_record);
						}
					});
				
				
				
				
				this.output = (TextView) this.findViewById(R.id.txtOutput);
				this.text_name = (TextView) this.findViewById(R.id.text_name);
		        
		        this.dh = new DataHelper(this);
		        
		        //Date date_now = new Date();
		        /*final Calendar c = Calendar.getInstance();
		        
		        int mYear = c.get(Calendar.YEAR);
		        
		        int mMonth = c.get(Calendar.MONTH);
		       
		        int mDay = c.get(Calendar.DAY_OF_MONTH);
		        
		        String date = Integer.toString(mDay);
		        date = date+Integer.toString(mMonth);
		        String date_now = date+Integer.toString(mYear);
		        
		        date_now ="02262012";
		        */
		        
		        this.dh.insert(strReceipInput1,strReceipInput2,strReceipInput3,strReceipInput4,strReceipInput5,strReceipInput6,strReceipInput7);
		        
		        this.text_name.setText(strReceipInput1.toString());
		        
		        this.output.setText(strReceipInput5.toString());
				
		        /*List<String> allData = this.dh.selectAll();
		        StringBuilder sb = new StringBuilder();
		        sb.append("Data in database:\n");
		        int i = 0;
		        for (String name : allData) {
		           sb.append(name + " "); //name = allData
		           i = i+1;
		           if( i%4==0)
		           {
		        	   sb.append("\n");
		           }
		           
		        }
		         
		        Log.d("EXAMPLE", "names size - " + allData.size());
		         
		        this.output.setText(sb.toString());
		        */
		        
								 
	}
	
			 

}
